﻿package zpx.util;

import java.util.Properties;

import org.apache.log4j.Logger;


public class PropertyReader {

	 private static Properties props=new Properties();
		private final Logger logger = Logger.getLogger(getClass());
	    public PropertyReader(){
	    	  loadConfigFile("wltx.properties");
	    }
	    public PropertyReader(String fileName){
	    	  loadConfigFile(fileName);
	    	
	    }
		private  void loadConfigFile(String fileName) {
				try {
					java.io.InputStream fis = getClass().getResourceAsStream("/" + fileName);
					props.load(fis);
					//props.load(new FileInputStream("/"+fileName));
				}
				catch(Exception e) {
					logger.error("load file failed!",e);
				}
		}
		public String getProperty(String key){
			 return props.getProperty(key);
		}
		public int size(){
			return props.size();
		}	
		public Properties getProperties(){
			return props;
		}
		
		
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		PropertyReader pr = new PropertyReader("wltx.properties");
		String orgnum = pr.getProperty(null+"");
		System.out.println(orgnum==null?"":orgnum);

	}

}
